#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=100010;
int T,n,m,L,V,ans1,ans2,AB;
int p[N],speed,oo;
int h[110],b[110],len;
bool f;
struct node{
    int d,v,a;
}a[N];
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>T;
    while (T--){
        ans1=0,ans2=0,AB=0;
        cin>>n>>m>>L>>V;
        for (int i=1;i<=n;i++){
            cin>>a[i].d>>a[i].v>>a[i].a;
            if (a[i].a==0) AB++;
        }
        for (int i=1;i<=m;i++){
            cin>>p[i];
        }
        if (AB==n){
            ans2=m-1;
            for (int i=1;i<=n;i++){
                if (a[i].d<=p[m]&&a[i].v>V) ans1++;
            }
            if (ans1==0) ans2=m;
            cout<<ans1<<' '<<ans2<<endl;
            continue;
        }
        sort(p+1,p+1+m);
        for (int i=1;i<=n;i++){
            f=true;
            for (int j=1;j<=m;j++){
                if (p[j]<a[i].d) continue;
                speed=a[i].v*a[i].v+2*a[i].a*(p[j]-a[i].d);
                if (speed>V*V) {
                    f=false;
                    break;
                }
            }
            if (f==false) ans1++;
        }
        int po=pow(2,m)-1,anss=0;
        for (int o=1;o<=po;o++){
            oo=o;anss=0;len=0;
            for (int i=1;i<=m;i++){
                h[i]=oo%2;
                if (h[i]==0) anss++;
                oo/=2;
            }
            for (int i=1;i<=m;i++){
                if (h[i]==1) {
                    for (int j=1;j<=n;j++){
                        int qq=0;
                        for (int q=1;q<=len;q++){
                            if (b[q]==j) qq=1;
                        }
                        if (qq==1) continue;
                        if (p[i]<a[j].d) continue;
                        speed=a[j].v*a[j].v+2*a[j].a*(p[i]-a[j].d);
                        if (speed>V*V) {
                            len++;
                            b[len]=j;
                        }
                    }
                }
            }
            if (len==ans1) ans2=max(ans2,anss);
        }
        cout<<ans1<<' '<<ans2<<endl;
    }
    return 0;
}
//20pts(A)+20pts(n,m<=20)=40pts